/**
 * 
 */
package com.lunevich.json.wrappers;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author Andrei_Lunevich
 * 
 */
public class JSONWrapper {

	private JSONObject jo;

	public JSONWrapper(JSONObject jo) {
		super();
		this.jo = jo;
	}

	public JSONWrapper(String jsonString) throws JSONException {
		super();
		this.jo = new JSONObject(jsonString);
	}

	public JSONWrapper() {
		super();
		this.jo = new JSONObject();
	}

	public String getString(String key) {
		try {
			if (jo.isNull(key)) {
				return null;
			}
			return jo.getString(key);
		} catch (JSONException e) {
			return null;
		}
	}

	public Long getLong(String key) {
		try {
			if (jo.isNull(key)) {
				return null;
			}
			return jo.getLong(key);
		} catch (JSONException e) {
			return null;
		}
	}
}